//Search模块的小仓库
import {reqGetSearchInfo} from '@/api'
// actions 处理异步，接受服务器端的数据
const actions = {
  async GetSearchList(context,params={}){
    //当前这个reqGetSearchInfo这个函数在调用获取服务器数据的时候，至少传递一个参数
    let result = await reqGetSearchInfo(params)
      // console.log(result)
      if(result.code==200){
        context.commit('GETSEARCHLIST',result.data)
      }
  }
}
//mutations 修改state的唯一方法
const mutations = {
  GETSEARCHLIST(state,searchList){
    state.searchList = searchList
  }
}
//state仓库存储数据
const state = {
  searchList:{}
}
// getters 计算属性，组件获取仓库的数据更加方便
const getters = {
  goodsList(state){
    // console.log(state)
    return state.searchList.goodsList||[]
  },
  attrsList(state){
    return state.searchList.attrsList||[]
  },
  trademarkList(state){
    return state.searchList.trademarkList||[]
  },

}
export default {
    state,
    actions,
    mutations,
    getters,
  };